import axios from 'axios'

const instance =axios.create({
  baseURL:'/api'
})

// 请求拦截
instance.interceptors.request.use(config =>{
  return config

},error => error)

// 响应拦截
instance.interceptors.response.use(res =>{
  
  return res.data
},error => error)

export const request= {
  get: function(config) {
    return instance({
      ...config,
      method: 'GET',
      params: config.data
    })
  },
  post: function(config) {
    return instance({
      ...config,
      method: 'POST'
    })
  }
}